"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const vue = require("vue");
const antDesignVue = require("ant-design-vue");
const _hoisted_1 = { class: "me-dynamic-form" };
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
  ...{
    name: "me-dynamic-form"
  },
  __name: "dynamic-form",
  props: {
    formProps: { default() {
      return {};
    } },
    dataSource: { default() {
      return [];
    } }
  },
  setup(__props, { expose: __expose }) {
    const props = __props;
    const componentMapper = vue.ref({
      Input: vue.shallowRef(antDesignVue.Input),
      InputSearch: vue.shallowRef(antDesignVue.InputSearch),
      Select: vue.shallowRef(antDesignVue.Select),
      Checkbox: vue.shallowRef(antDesignVue.Checkbox),
      CheckboxGroup: vue.shallowRef(antDesignVue.CheckboxGroup),
      Cascader: vue.shallowRef(antDesignVue.Cascader),
      DatePicker: vue.shallowRef(antDesignVue.DatePicker),
      RangePicker: vue.shallowRef(antDesignVue.RangePicker),
      TimePicker: vue.shallowRef(antDesignVue.TimePicker),
      InputNumber: vue.shallowRef(antDesignVue.InputNumber),
      Textarea: vue.shallowRef(antDesignVue.Textarea),
      Radio: vue.shallowRef(antDesignVue.Radio),
      RadioGroup: vue.shallowRef(antDesignVue.RadioGroup),
      Switch: vue.shallowRef(antDesignVue.Switch),
      Upload: vue.shallowRef(antDesignVue.Upload),
      TreeSelect: vue.shallowRef(antDesignVue.TreeSelect),
      TimeRangePicker: vue.shallowRef(antDesignVue.TimeRangePicker),
      Button: vue.shallowRef(antDesignVue.Button),
      Custom: vue.shallowRef(null),
      InputPassword: vue.shallowRef(antDesignVue.InputPassword)
    });
    const formRef = vue.ref();
    __expose({
      instance: formRef
    });
    return (_ctx, _cache) => {
      return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
        vue.createVNode(vue.unref(antDesignVue.Form), vue.mergeProps({
          ref_key: "formRef",
          ref: formRef
        }, _ctx.formProps), {
          default: vue.withCtx(() => [
            (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.dataSource, (item) => {
              return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [
                item instanceof Array ? (vue.openBlock(), vue.createBlock(vue.unref(antDesignVue.Row), {
                  key: 0,
                  gutter: [16, 16]
                }, {
                  default: vue.withCtx(() => [
                    (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(item, (a, index) => {
                      return vue.openBlock(), vue.createBlock(vue.unref(antDesignVue.Col), {
                        key: index,
                        span: a.span || Math.floor(24 / item.length)
                      }, {
                        default: vue.withCtx(() => [
                          vue.createVNode(vue.unref(antDesignVue.FormItem), vue.mergeProps(vue.toHandlers(a.formItemListeners || {}), { ref_for: true }, a.formItemProps), {
                            default: vue.withCtx(() => [
                              a.component === "Custom" ? vue.renderSlot(_ctx.$slots, a.slot, {
                                key: 0,
                                item: a
                              }) : (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(componentMapper.value[a.component]), vue.mergeProps({ key: 1 }, vue.toHandlers(a.formItemControlListeners || {}), {
                                [a.modelType]: _ctx.formProps.model[a.formItemProps.name],
                                ["onUpdate:" + a.modelType]: ($event) => _ctx.formProps.model[a.formItemProps.name] = $event,
                                ref_for: true
                              }, a.formItemControlProps), null, 16))
                            ]),
                            _: 2
                          }, 1040)
                        ]),
                        _: 2
                      }, 1032, ["span"]);
                    }), 128))
                  ]),
                  _: 2
                }, 1024)) : (vue.openBlock(), vue.createBlock(vue.unref(antDesignVue.FormItem), vue.mergeProps({ key: 1 }, vue.toHandlers(item.formItemListeners || {}), { ref_for: true }, item.formItemProps), {
                  default: vue.withCtx(() => [
                    item.component === "Custom" ? vue.renderSlot(_ctx.$slots, item.slot, {
                      key: 0,
                      item
                    }) : (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(componentMapper.value[item.component]), vue.mergeProps({ key: 1 }, vue.toHandlers(item.formItemControlListeners || {}), {
                      [item.modelType]: _ctx.formProps.model[item.formItemProps.name],
                      ["onUpdate:" + item.modelType]: ($event) => _ctx.formProps.model[item.formItemProps.name] = $event,
                      ref_for: true
                    }, item.formItemControlProps), null, 16))
                  ]),
                  _: 2
                }, 1040))
              ], 64);
            }), 256)),
            vue.renderSlot(_ctx.$slots, "default")
          ]),
          _: 3
        }, 16)
      ]);
    };
  }
});
exports.default = _sfc_main;
//# sourceMappingURL=dynamic-form.vue2.cjs.map
